//
//  MovieModel.m
//  Movie
//
//  Created by cjy on 16/3/23.
//  Copyright © 2016年 HY. All rights reserved.
//

#import "MovieModel.h"

@implementation MovieModel

//归档时自动调用
- (void)encodeWithCoder:(NSCoder *)aCoder {
    //将需要保存的属性进行编码
    [aCoder encodeObject:self.category forKey:@"category"];
    [aCoder encodeObject:self.collectionCount forKey:@"collectionCount"];
    [aCoder encodeObject:self.title forKey:@"title"];
    [aCoder encodeObject:self.ID forKey:@"id"];
    [aCoder encodeObject:self.replyCount forKey:@"replyCount"];
    [aCoder encodeObject:self.shareCount forKey:@"shareCount"];
    [aCoder encodeObject:self.coverBlurred forKey:@"coverBlurred"];
    [aCoder encodeObject:self.coverForDetail forKey:@"coverForDetail"];
    [aCoder encodeObject:self.descrip forKey:@"description"];
    [aCoder encodeObject:self.title forKey:@"title"];
    [aCoder encodeObject:self.playUrl forKey:@"playUrl"];

}

//反归档时自动调用
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    
    self = [self init];
    
    if (self) {
        
        self.category = [aDecoder decodeObjectForKey:@"category"];
        self.collectionCount = [aDecoder decodeObjectForKey:@"collectionCount"];
        self.title = [aDecoder decodeObjectForKey:@"title"];
        self.ID = [aDecoder decodeObjectForKey:@"id"];
        self.replyCount = [aDecoder decodeObjectForKey:@"replyCount"];
        self.playUrl = [aDecoder decodeObjectForKey:@"playUrl"];
        self.shareCount = [aDecoder decodeObjectForKey:@"shareCount"];
        self.coverBlurred = [aDecoder decodeObjectForKey:@"coverBlurred"];
        self.coverForDetail = [aDecoder decodeObjectForKey:@"coverForDetail"];
        self.descrip = [aDecoder decodeObjectForKey:@"description"];
        self.shareCount = [aDecoder decodeObjectForKey:@"shareCount"];
        
    }
    return self;
}




- (void)setValue:(id)value forUndefinedKey:(NSString *)key{
    
    if ([key isEqualToString:@"description"]) {
        
        self.descrip = value;
        
    }
    
    if ([key isEqualToString:@"id"]) {
        
        self.ID = [value stringValue];
        
    }
    
}

- (void)setValue:(id)value forKey:(NSString *)key{
    
    [super setValue:value forKey:key];
    
    if ([key isEqualToString:@"duration"]) {
        
        self.duration = [value doubleValue];
    }
    
}


@end
